package com.sphd.Restaurant.base;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import com.sphd.Restaurant.utils.BitmapCache;
import com.sphd.Restaurant.utils.Constants;
import com.sphd.Restaurant.utils.VolleyUtil;

/**
 * Created by Hu on 2016/10/24.
 */

public class MyApplication extends Application {
    private static ImageLoader imageLoader;
    private static RequestQueue requestQueue;
    private static SharedPreferences remember;
    private static VolleyUtil volleyUtil;;
    private static Context context;;

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("onCreate","onCreate");
        volleyUtil=new VolleyUtil();
        context=getApplicationContext();
        requestQueue = Volley.newRequestQueue(getApplicationContext());
        remember = getSharedPreferences("remeber", Context.MODE_PRIVATE);
        imageLoader = new ImageLoader(requestQueue, new BitmapCache());
        Log.e("RE============",remember.contains(Constants.ISLOGIN)+"");
        Log.e("PWD============",remember.contains(Constants.PWD)+"");
        if (remember.contains(Constants.ISLOGIN)) {
            if (!remember.contains(Constants.PWD)){
                remember.edit().remove(Constants.ISLOGIN).commit();
                remember.edit().remove(Constants.USERPHONE).commit();
                remember.edit().remove(Constants.USERPHOTO).commit();
            }
        }



    }

    public static Context getContext() {
        return context;
    }

    public static VolleyUtil getVolleyUtil() {
        return volleyUtil;
    }

    public static ImageLoader getImageLoader() {
        return imageLoader;
    }

    public static RequestQueue getRequestQueue() {
        return requestQueue;
    }

    public static SharedPreferences getRemember() {
        return remember;
    }

}
